package cn.richx.pushmessage.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Objects;

/**
 * A BaseDatasource.
 */
@Entity
@Table(name = "kf_base_datasource", catalog = "uaa")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class BaseDatasource implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Size(max = 20)
    @Column(name = "user_name", length = 20, nullable = false)
    private String userName;

    @NotNull
    @Size(max = 45)
    @Column(name = "password", length = 45, nullable = false)
    private String password;

    @NotNull
    @Size(max = 255)
    @Column(name = "url", length = 255, nullable = false)
    private String url;

    @NotNull
    @Size(max = 100)
    @Column(name = "driver_class", length = 100, nullable = false)
    private String driverClass;

    @MapsId
    @OneToOne
    @JoinColumn(unique = true, name = "id")
    private Base base;

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public BaseDatasource userName(String userName) {
        this.userName = userName;
        return this;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public BaseDatasource password(String password) {
        this.password = password;
        return this;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUrl() {
        return url;
    }

    public BaseDatasource url(String url) {
        this.url = url;
        return this;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getDriverClass() {
        return driverClass;
    }

    public BaseDatasource driverClass(String driverClass) {
        this.driverClass = driverClass;
        return this;
    }

    public void setDriverClass(String driverClass) {
        this.driverClass = driverClass;
    }

    public Base getBase() {
        return base;
    }

    public BaseDatasource base(Base base) {
        this.base = base;
        return this;
    }

    public void setBase(Base base) {
        this.base = base;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        BaseDatasource baseDatasource = (BaseDatasource) o;
        if (baseDatasource.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), baseDatasource.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "BaseDatasource{" +
            "id=" + getId() +
            ", userName='" + getUserName() + "'" +
            ", password='" + getPassword() + "'" +
            ", url='" + getUrl() + "'" +
            ", driverClass='" + getDriverClass() + "'" +
            "}";
    }
}
